package org.example.model;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

@Service
public class TestCat {
     @Autowired
     Cat cat;
    public void testCat(){
        cat.eat();
        System.out.println(cat.getAge());
        System.out.println(cat.getName());
    }
    public static void main(String[] args) {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
        //加载配置文件
       TestCat  cat = context.getBean(TestCat.class);
       cat.testCat();
        /*

         *//*  Cat cat = (Cat) context.getBean("cat");
        Cat cat1 = (Cat) context.getBean("cat");
        System.out.println(cat);
        System.out.println(cat1);
        cat.eat();
        cat.setName("小白");*//*

        Cat cat1 = (Cat) context.getBean("cat3");
        System.out.println(cat1.getAge()+cat1.getName());

    }*/
    }
}
